import allure
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions

from automation_ui.base.base import BasePage
from automation_ui.page.coupon_manage import CouponPage
from automation_ui.untils.log_util import logger


class PromotionPage(BasePage):
    __promotion = By.XPATH, "//*[text()='推广管理']"
    __coupon = By.XPATH, "//*[text()='优惠券管理']"

    @allure.step('推广管理')
    def coupon_page(self):
        """
        推广管理中优惠券管理入口
        :return:
        """
        self.wait(expected_conditions.element_to_be_clickable(self.__promotion))
        self.click(self.__promotion)
        self.click(self.__coupon)
        logger.info('推广管理')
        self.screencap()
        self.source()

        return CouponPage(self.driver)
